﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Design;
using ProgNetDxComponents.ExtenderProviders.Language;

namespace ProgNetDxComponents.Design.Editors
{
    public class RadioItemLngInfoCollectionEditor : ProgNetComponents.Design.Editors.NamedCollectionEditor
    {
        public RadioItemLngInfoCollectionEditor(Type type)
            : base(type)
        {
            
        }
        public override bool AllowCopy
        {
            get
            {
                return false;
            }
        }
        protected override bool AllowAddOrRemove
        {
            get
            {
                return false;
            }
        }
        protected override bool AllowChangeOrder
        {
            get
            {
                return false;
            }
        }
        protected override bool CanSelectMultipleInstances()
        {
            return false;
        }
        protected override object CreateInstance(Type itemType)
        {
            RadioItemLngInfo o = base.CreateInstance(itemType) as RadioItemLngInfo;
            o.Collection = Collection.Collection;
            return o;
        }
        
        protected RadioItemLngInfoCollection Collection;
         
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            Collection = value as RadioItemLngInfoCollection;
            "EditValue".Log();
            if (Collection != null)
            {
                Collection.InitRadioSettings();
                foreach (RadioItemLngInfo obj in Collection)
                {
                    obj.Collection = Collection.Collection;
                }
            }
            return base.EditValue(context, provider, value);
        }
    }
}
